﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GenerateIndexPage.aspx.cs" Inherits="ncp.Web.cms.work.HomeManager.GenerateIndexPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
	<script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../js/common.js"></script>
</head>
<body style="margin:0; padding:0px;">
    <form id="form1" runat="server">
        <div class="toolbar" style="background-color:#efefef">
            <asp:Button ID="Button1" runat="server"  Text="发布行业分类" onclick="Button1_Click" />
        </div>
        <div id="divright">    
        </div>
	</form>
</body>

</html>
<script type="text/javascript">
    var rowIndex_List = "0";
    $(function() {
        initDatagrid();
        LoadGoodsInfo();
    });


    //初始化表格
    function initDatagrid() {
        $('#divright').datagrid({
            height: $(window).height() - 61,
            nowrap: true,
            striped: true,
            singleSelect: true,
            sortName: 'G_Code',
            sortOrder: 'asc',
            remoteSort: false,
            idField: 'G_Id',
            pagination: false,
            rownumbers: true,
            columns: [[
					{ field: 'G_Id', title: '商品ID', hidden: 'true', width: 80 },
					{ field: 'G_Code', title: '商品编号', sortable: 'true', width: 120 },
					{ field: 'G_Name', title: '商品名称', sortable: 'true', width: 250 },
					{ field: 'GC_Name', title: '商品类别', sortable: 'true', width: 80, align: 'center' },
					{ field: 'G_Flag', title: '发布位置', sortable: 'true', width: 80, align: 'center',
					    formatter: function(value, rec) {
					        var strReturn = "";
					        if (value == null) return strReturn; ;
					        if (value.indexOf('h') >= 0) {
					            strReturn += "首页 ";
					        }
					        return strReturn;
					    }
					},
					{ field: 'G_StatusName', title: '状态', sortable: 'true', width: 60, align: 'center',
					    styler: function(value, row, index) {
					        if (value == '禁用') {
					            return 'background-color:#6293BB;color:#fff;font-weight:bold;';
					        }
					    }
					}
				]]
        });
    }


    //装载商品信息视图
    function LoadGoodsInfo() {
        var data = eval(ncp.Web.cms.work.HomeManager.GenerateIndexPage.BindTable().value);
        $('#divright').datagrid('loadData', data);
    }

    //发布商品
    function onReleaseGoods() {
        if (confirm("您确定要发布吗？")) {
            var response = ncp.Web.cms.work.HomeManager.GenerateIndexPage.ReleaseGoods();
            if (response.value != null) {
                var jsonOBJ = eval(response.value)[0];
                if (jsonOBJ.isreload) {
                    LoadGoodsInfo();
                }
                alert(jsonOBJ.msg);
            }
        }
        return false;
    }
    
</script>
